<template>
  <div>
    <el-dialog
      :visible.sync="showDialog"
      :before-close="handleClose"
      width="380px"
      custom-class="dialog">
      <div class="dialog-header flex flex-center"><img :src="tip">供应商已存在，无法{{ editExist? '编辑' : '新建' }}</div>
      <div class="dialog-tip">
        <p>1. 请在列表搜索该供应商；</p>
        <p>2. 如果搜索不到该供应商，请向以下人员申请成为协作人以获取查看权限；</p>
      </div>
      <div class="dialog-user flex">
        <div v-for="(item, index) in data" :key="index" class="user-item">
          <userCard :user-data="item" :size="40" class="mr10"/>
          <p>{{ item.name }}</p>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import tip from '@/assets/customer/tip_icon.png';
import UserCard from '@/components/Common/userCard';

export default {
  components: { UserCard },
  props: {
    showDialog: {
      type: Boolean,
      default: false
    },
    editExist: {
      type: Boolean,
      default: false
    },
    data: {
      type: Array,
      default() {
        return [];
      }
    }
  },
  data() {
    return {
      tip
    };
  },
  methods: {
    handleClose() {
      this.$emit('handleClose');
    }
  }
};
</script>

<style scoped lang="scss">
::v-deep .el-dialog {
  border-radius: 12px;
  .el-dialog__header {
    padding: 0;
  }
  .el-dialog__body {
    padding: 0;
  }
}

.dialog-header {
  height: 48px;
  padding: 0 24px;
  background-color: #FFF2EB;
  border-radius: 12px 12px 0px 0px;
  font-size: 16px;
  color: #333;
  font-weight: bold;
  img {
    width: 24px;
    margin-right: 12px;
  }
}
.dialog-tip {
  padding: 0 24px;
  font-size: 14px;
  color: #666;
}
.dialog-user {
  width: 100%;
  flex-wrap: wrap;
  padding: 0 24px 30px;
  .user-item {
    width: 25%;
    margin-bottom: 6px;
    p {
      width: 50px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      margin: -5px 0 0;
      padding-left: 4px;
      font-size: 12px;
      color: #999;
    }
  }
}
</style>
